let _BASE_URL_ = '/disable-aid-acis'

/** 公共请求方法 **/
const request = ((url, data = {}, method = 'GET', contentType = 'application/x-www-form-urlencoded') => {
	return new Promise((resolve, reject) => {
		let token = uni.getStorageSync('token') || ''
		uni.request({
			url: _BASE_URL_ + url,
			data: data,
			method: method,
			header: {
				'Authorization': 'Bearer ' + token,
				'Content-Type': contentType,
			},
			success: (res) => {
				if (res.statusCode === 200) {
					resolve(res.data);
				} else {
					reject(err);
				}
			},
			fail: (err) => {
				//console.log(err);
				reject(err);
			}
		});
	});
});

/** 以GET方式提交表单数据 **/
const getForm = ((url, data) => {
	return request(url, data);
});
/** 以POST方式提交表单数据 **/
const postForm = ((url, data) => {
	return request(url, data, 'POST');
});
/** 以POST方式提交JSON数据 **/
const postJson = ((url, data) => {
	return request(url, data, 'POST', 'application/json');
});

export default {
	request,
	getForm,
	postForm,
	postJson
}
